package home.my.base.sql;

import home.my.base.annotation.SingleValue;

import java.io.Serializable;
import java.lang.annotation.Annotation;

public class SingleValueFactory extends AnnotationConditionFactory{

	/* (non-Javadoc)
	 * @see com.shunwang.framework.ibatis.annotation.factory.AnnotationConditionFactory#build(java.lang.annotation.Annotation, java.lang.Object)
	 */
	@Override
	public AbsCondition build(Annotation annotation, String column, Object value) {
		
		if(value==null || !(value instanceof Serializable))
			return null;
		SingleValue singleValue = (SingleValue)annotation;
			
		if(column==null) column = singleValue.column();
		return new SingleValueCondition(singleValue.tableAlias(),column,singleValue.equal(),(Serializable)value);
	}

}
